I have been reflecting on what it’s so hard to learn command-line tools, especially for new students.
The truth is that working well on the command line requires a lot of practice. The time between feeling like a newbie versus feeling comfortable on the command line is a lot.
- Command line work is not one skill, but a bunch of skills together. Instructors often forget how many skills that are needed to even install tools, much less work with text editors, and it’s easy for students to get frustrated here.
- There are conflicting toolchains and we don’t emphasize advantges/disadvantages of each. One example is: using Conda versus Homebrew - what are the differences and can they work together? Conda environments are extremely powerful, but again, it’s something else to learn on top of everything else.
- Command line a new paradigm for interacting with the computer for most people. It is a brave new world that many of us have heard about, but has seemed daunting for a lot of people.
- File systems are hard. One unforseen consequence of mobile phones and browsers hiding file locations has been this unawareness of file structure.
- It’s unforgiving. It can be hard to spot mistakes You think that you understand how to input a command, but the responses from the shell can be very hard to understand and read.
- The options are overwhelming. You look at the manual page for something like
ls, and there are literally 20 options with no guidance.
- Sequencing learning is difficult. One example: when you teach piping, do you cover the individual functions and then discuss the pipe? What about pipelines where the format is changing from command to command?
- There is always a pervasive feeling of “am I doing this right?” Even after years of working on the command line, I still have a pervasive sense that I don’t understand certain commands, such as remembering the options for
tar. - Variable expansion has so many gotchas. Variable expansion (substituting the value of a variable in an expression) is extremely powerful. However, there are many ways to expand variables:
$var_name,${var_name}, and$(var_name). - Quoting and escaping. Without IDEs, nested quotations can be a pain.
Solutions
- Emphasize code reading and literacy before anything else. Take code apart word for word so that every part is accounted for. Don’t use “that part is just there because…” Explain everything.
- Use a gradual approach to teaching options/flags. Use examples that build on each other to teach new concepts, or start from scratch.
- Emphasize the main use cases/options for commands. I really love Julia Evans’ comics, where she highlights the main uses for a function (see below for an example with
xargs). She doesn’t get bogged down in all of the minutiae, which can really overwhelm students. Utilities such astldrare very helpful to students. - Use iterative learning to build knowledge. This is especially helpful when building pipelines that transform incoming data from one format to another.
- Show intermediate outputs for pipes.
- De-emphasize reading of man pages for concrete examples.
Citation
BibTeX citation:
@online{laderas,
author = {Laderas, Ted},
title = {Why Is {Learning} {Command} {Line} so Hard?},
url = {https://laderast.github.io//posts/2022-10-27-why-is-command-line},
langid = {en}
}
For attribution, please cite this work as:
Laderas, Ted. n.d. “Why Is Learning Command Line so Hard?”
https://laderast.github.io//posts/2022-10-27-why-is-command-line.